﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using BaseControls;

namespace BaseControls
{
    public class MenuItem<BeforeEventArgs, AfterEventArgs>
        where BeforeEventArgs : EventArgs,new()
        where AfterEventArgs : EventArgs,new()
    {
        public event EventHandler<BeforeEventArgs> BeforeCommandEvent;           
        public event EventHandler<AfterEventArgs> AfterCommandEvent;        
        protected virtual void OnAfterCommand(AfterEventArgs args)
        {
            if(AfterCommandEvent!=null)
                AfterCommandEvent(this,args);
        }
        protected virtual void OnBeforeCommand(BeforeEventArgs args)
        {
            if(BeforeCommandEvent != null)
                BeforeCommandEvent(this,args);
        }        
    }
    public class StartGame : MenuItem<EventArgs,EventArgs>,ICommand
    {
        public StartGame():base()
        {

        }        
        public void Do(FrameworkElement AssociatedObject)
        {
            OnBeforeCommand(new EventArgs());
            LogicalTreeHelper.FindName("FrameControl",AssociatedObject);            
            OnAfterCommand(new EventArgs());
        }
    }
}
